package com.macro.mall.es.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.es.dto.DocSaveDto;
import com.macro.mall.es.service.EsDocService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/doc")
public class EsDocController {
    @Autowired
    private EsDocService esDocService;

    /**
     * 批量添加
     * @param docSaveDto
     * @return
     */
    @PostMapping("/batchInsert")
    public CommonResult batchInsert(DocSaveDto docSaveDto) {
        esDocService.batchInsert(docSaveDto);
        return CommonResult.success("批量插入成功");
    }

    /**
     * 批量删除
     * @param docSaveDto
     * @return
     */
    @DeleteMapping("/delBatch")
    public CommonResult delBatch(DocSaveDto docSaveDto) {
        esDocService.delBatch(docSaveDto);
        return CommonResult.success("批量删除成功");
    }

    /**
     * 修改商品上下架
     * @param docSaveDto
     * @return
     */
    @PutMapping("/updateStatus")
    public CommonResult updateStatus(DocSaveDto docSaveDto) {
        esDocService.updateStatus(docSaveDto);
        return CommonResult.success("更新状态成功");
    }

}
